<?php

namespace app\api\controller;

use app\admin\model\Banner;
use app\common\controller\Api;

/**
 *
 */
class Auctionfollow extends Api
{
    protected $noNeedRight = ['*'];

    public function add()
    {
        $model = new \app\api\model\AuctionFollow();

        $data = [
            'user_id'=>$this->auth->id,
            'auction_id'=>input('auction_id',0)
        ];
        $info = \app\api\model\AuctionFollow::get($data);
        if ($info){
           $this->error('已关注');
        }
        $res = $model->save($data);

        \app\api\model\Auction::where(['auction_id'=>$data['auction_id']])->setInc('follow_num');

        $this->success('请求成功',$res);
    }

    public function isfollow()
    {
        $auction_id = input('auction_id',0);

        $info = \app\api\model\AuctionFollow::get(['user_id'=>$this->auth->id,'auction_id'=>$auction_id]);
        $this->success('请求成功',$info?1:0);
    }
}